// 熔铸滤镜
const casting = function (imgData) {
    for (let i = 0; i < imgData.height * imgData.width; i++) {
        let r = imgData.data[i*4],
            g = imgData.data[i * 4+1],
            b = imgData.data[i * 4+2];

        let newR = r * 128 / (g + b + 1);
        let newG = g * 128 / (r + b + 1);
        let newB = b * 128 / (g + r + 1);
        let rgbArr = [newR, newG, newB].map((e) => {
            return e < 0 ? 0 : e > 255 ? 255 : e;
        });
        [imgData.data[i*4], imgData.data[i * 4+1], imgData.data[i * 4+2]] = rgbArr;
    }

    return imgData;
}

export default casting;